package demo2;

public class Main {
    public static void main(String[] args) {
        Player Md = new Guards("特雷西麦格雷迪");
        Md.Attack();
        Md.Defense();

        Player ONier = new Center("沙奎尔奥尼尔");
        ONier.Attack();
        ONier.Defense();

        Player LBJ = new Forwards("勒布朗詹姆斯");
        LBJ.Attack();
        LBJ.Defense();

        //姚明是外籍中锋 听不懂Attack 和Defense 是什么意思
        //于是就需要翻译(适配器)
        Player YM = new Translator("姚明");
        YM.Attack();
        YM.Defense();
     }
}

abstract class Player{
    protected String name;
    public Player(String name){
        this.name = name;
    }
    public abstract void Attack(); //进攻方法
    public abstract void Defense();//防守方法
}

class Forwards extends Player{
    public Forwards(String name) {
        super(name);
    }
    //前锋类

    @Override
    public void Attack() {
        System.out.println("前锋: "+super.name + " 快攻一条龙 持球暴扣 ");
    }

    @Override
    public void Defense() {
        System.out.println("前锋 :"+super.name + " 使用二三联防");
    }

}

class Center extends Player{ //中锋
    public Center(String name) {
        super(name);
    }

    @Override
    public void Attack() {
        System.out.println("中锋: "+super.name+ " 使用梦幻脚步 塔下秀");
    }

    @Override
    public void Defense() {
        System.out.println("中锋: "+super.name+ " 请对方吃一记大火锅");
    }
}

class Guards extends Player{
    public Guards(String name) {
        super(name);
    }

    @Override
    public void Attack() {
        System.out.println("后卫： "+super.name+" 干拔跳投 手起刀落");
    }

    @Override
    public void Defense() {
        System.out.println("后卫： "+super.name+" 人盯人防守 盯紧了");
    }
}

class ForeignCenter{
    //外籍中锋类
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public void 进攻(){
        System.out.println("外籍中锋: "+ name + " 进攻");
    }
    public void 防守(){
        System.out.println("外籍中锋: "+ name + " 防守");
    }
}

class Translator extends Player{
    //翻译者
    private ForeignCenter foreignCenter = new ForeignCenter();

    public Translator(String name) {
        super(name);
        foreignCenter.setName(name);
    }

    @Override
    public void Attack() {
        foreignCenter.进攻();
    }

    @Override
    public void Defense() {
        foreignCenter.防守();
    }
}